/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.admin.dto.ElevatorPrincipalQueryDTO;
import org.springblade.modules.admin.dto.ElevatorSaveDto;
import org.springblade.modules.admin.dto.feishu.ElevatorMaintainCostListDTO;
import org.springblade.modules.admin.dto.feishu.GalaxyElevatorTrackUpdateDTO;
import org.springblade.modules.admin.dto.platform.BuildingSearchDTO;
import org.springblade.modules.admin.entity.Elevator;
import org.springblade.modules.admin.entity.ElevatorBrand;
import org.springblade.modules.admin.entity.ElevatorDetail;
import org.springblade.modules.admin.vo.*;
import org.springblade.modules.admin.vo.elevator.ElevatorIntactSearchVo;
import org.springblade.modules.admin.vo.elevator.ElevatorIntactVo;
import org.springblade.modules.admin.vo.feishu.BuildingElevatorFeiShuVO;
import org.springblade.modules.admin.vo.feishu.ElevatorDataReportVO;
import org.springblade.modules.admin.vo.feishu.GalaxyElevatorNumVO;
import org.springblade.modules.admin.vo.feishu.GovernmentElevatorPoolVO;
import org.springblade.modules.admin.vo.openapi.SidaElevatorBasicVO;
import org.springblade.modules.admin.vo.platform.ElevatorVo;
import org.springblade.modules.admin.vo.platform.TenantVO;
import org.springblade.modules.admin.vo.sugar.bi.BIScreenElevatorPlanPartsVO;
import org.springblade.modules.admin.vo.sugar.bi.BIScreenElevatorVO;
import org.springblade.modules.admin.vo.sugar.bi.BIScreenElevatorPlanVO;
import org.springblade.modules.admin.vo.sugar.estate.ElevatorInfoVo;
import org.springblade.modules.system.entity.Dict;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 电梯信息 服务类
 *
 * @author BladeX
 * @since 2021-05-11
 */
public interface ElevatorService extends BaseService<Elevator> {

    IPage<ElevatorVO> selectElevatorPage(IPage<ElevatorVO> page, Elevator elevator);

    IPage<ElevatorVO> selectElevatorPage(IPage<ElevatorVO> page, List<Long> elevatorIds);

    ElevatorVO selectElevator(Long id);

    ElevatorVO selectElevByPrivateNum(String privateNum, Long elevatorId);

    ElevatorVO selectElevatorByAddress(String elevatorAddress, Long buildingId);

    Long saveElevator(ElevatorSaveDto elevatorSaveDto);

    boolean updateElevator(Long id, ElevatorSaveDto elevatorSaveDto);

    List<ElevatorDetail> getListByBuildingId(Long buildingId, List<Long> elevatorIds);

    /**
     * 更新停梯状态
     *
     * @param elevatorId
     * @param isStop
     * @return
     */
    Boolean updateElevatorIsStop(Long elevatorId, Integer isStop);

    /**
     * 获取平台端电梯列表
     *
     * @param page              分页信息
     * @param buildingSearchDTO 查询条件
     * @return 数据集
     */
    IPage<ElevatorVo> elevatorListV2(IPage<ElevatorVo> page, BuildingSearchDTO buildingSearchDTO);

    /**
     * 获取电梯下拉列表
     *
     * @param buildingId
     * @return
     */
    List<ElevatorSimpleInfoVO> elevatorSelectList(Long buildingId);

    TlwElevatorDetailVO getTlwElevatorDetail(Long elevatorId);

    /**
     * 梯联网-获取电梯下拉列表（忽略租户）
     *
     * @param search
     * @return
     */
    List<ElevatorSimpleInfoVO> elevatorTlwSelectList(PlanConfigSearchVO search);

    /**
     * 根据项目id获取所关联的租户信息
     *
     * @param buildingSearchDTO 搜索条件
     * @return 数据集
     */
    List<TenantVO> elevatorTenantList(BuildingSearchDTO buildingSearchDTO);

    IPage<ElevatorPageVO> devicePage(IPage<Object> page, ElevatorSearchVO search);

    IPage<TlwElevatorPageVO> tlwPage(PlanConfigSearchVO search, IPage<TlwElevatorPageVO> page);

    List<TlwElevatorPageVO> selectElevatorByDeviceId(String deviceId);

    /**
     * 批量下载电梯码
     *
     * @param elevatorIds
     * @return
     */
    List<WxAppCodeVO> batchDownloadWxAppCode(List<Long> elevatorIds);

    /**
     * 生成小程序码
     *
     * @param elevatorId
     */
    String generateWxAppCode(Long elevatorId);

    /**
     * 电梯档案-列表
     *
     * @param page
     * @param elevator
     * @return
     */
    IPage<ElevatorDossierVO> elevatorDossierPage(IPage<ElevatorDossierVO> page, ElevatorVO elevator);

    /**
     * 获取所有的电梯
     *
     * @return 数据集
     */
    List<ElevatorInfoVo> getList(Long buildingId, String tenantId);

	/**
	 * 异步处理电梯年检时间
	 * @param elevatorList
	 */
	void auditTimeTask(List<Elevator> elevatorList);

	IPage<ElevatorPrincipalPageVO> selectElevatorPrincipalPage(IPage<ElevatorPrincipalPageVO> page, ElevatorPrincipalQueryDTO queryDTO);

	Map<String,Integer> selectElevatorPrincipalCount();

	/**
	 * 检测电梯信息是否齐全
	 * @param elevatorDetail
	 * @return false 不齐全，true齐全
	 */
	Boolean elevatorIsComplete(ElevatorDetail elevatorDetail);

	Boolean checkPrincipalDeptUser(String deptId, String userIds);

	void downExcelElevatorPrincipal(ElevatorPrincipalQueryDTO queryDTO, List<List<String>> rows);

	/**
	 * 根据电梯id查询电梯主表&电梯详情信息
	 * @param elevatorId
	 * @return
	 */
	ElevatorPageVO findElevatorPageVOByElevatorId(Long elevatorId);

	/**
	 * 根据未 删除的电梯 查询详情列表
	 * @return 电梯详情列表
	 */
    List<ElevatorDetail> listWithoutEleNum();

	/**
	 * 根据电梯唯一识别码 获取单台电梯
	 * @param page 分页参数
	 * @param elevatorNum 电梯唯一识别码
	 * @return 项目电梯列表
	 */
	IPage<ElevatorDossierVO> elevatorDossierPageByEleNum(IPage<ElevatorDossierVO> page, String elevatorNum);

    ElevatorRelationDetailVO selectElevatorRelationDetail(Long elevatorId);

    Map<String, Object> elevatorDossierCount();

	Boolean elevatorCheckAuditType(Long elevatorId, Integer useType);

    List<RobotElevatorSearchVO> getElevatorSearch(List<Long> buildingIds);

    List<Dict> driverModeFieldSelect(String code, String driverModeCode,String driverModeKey);

    Object testDetailFieldV();

	/**
	 * 梯联网-显示屏-电梯基础信息
	 * @param deviceId
	 * @return
	 */
	TlwScreenEleBaseInfoVO tlwScreenEleBaseInfo(String deviceId);

    void updateElevatorMaintainStatusDay();

    Boolean initElevatorMaintainDay();

	Boolean initMaintainDay();

    List<ElevatorSimpleInfoVO> selectAllElevatorSimpleInfo();

    List<ElevatorDeptUserSimpleVO> selectElevatorPrincipalDeptSimpleInfo();

	/**
	 * 查询所有电梯信息（忽略租户）
	 */
	List<ElevatorVO> selectAllElevatorDetailList();


	/**
	 * 维修大屏获取监控电梯的总数
	 * 维保中+非外包
	 * @return 数据集
	 */
	List<Elevator> getSugarMapEleList();

	/**
	 * 政府端-电梯池-电梯列表
	 * 租户写死 592800
	 * @return 数据集
	 */
	List<GovernmentElevatorPoolVO> queryGovernmentElevatorPoolVOList();

	/**
	 * 获取银河排期信息
	 * @return 数据集
	 */
	List<GalaxyElevatorTrackUpdateDTO> getGalaxyElevatorTrackUpdateDTO();

	/**
	 * 获取所有飞书自动扶梯/曳引梯检验报告数据
	 * @return 数据集
	 */
    List<ElevatorDataReportVO> getElevatorDataReportVO();

	/**
	 * 获取凤仪的飞书电梯唯一识别码
	 * @return 目标数据集
	 */
    List<GalaxyElevatorNumVO> getGalaxyElevatorNumVOs();

    List<BuildingElevatorFeiShuVO> queryBuildingElevatorVOList();

	/**
	 * 获取少维的配件协作流程表格飞书电梯唯一识别码
	 * @return 目标数据集
	 */
    List<PartPlanElevatorNumVO> getGalaxyPartsPlanElevatorNum();

	/**
	 * 获取政府端-电梯池-电梯列表-完整数据
	 * @return 数据集
	 */
	List<GovernmentElevatorPoolVO> queryGovernmentElevatorPoolVOFull();

	/**
	 * 获取电梯品牌
	 * @param elevatorIds 电梯ids
	 * @return 数据集
	 */
	List<ElevatorBrand> getBrandListOfElevatorId(String elevatorIds);


	/**
	 * 完整度数据初始化
	 */
	void elevatorInit(Elevator e);


	/**
	 * 电梯完整度分页列表
	 * @param elevatorIntactSearchVo 查询列表
	 * @return 数据集
	 */
	IPage<ElevatorIntactVo> pageList(ElevatorIntactSearchVo elevatorIntactSearchVo);
	/**
	 * 根据电梯id获取电梯类型
	 * @param elevatorId
	 * @return
	 */
	String getModeNameByElevatorId(Long elevatorId);

	/**
	 * 模糊搜素设备注册代码
	 * @param privateNum 设备注册代码
	 * @return 数据集
	 */
	List<ElevatorSearchConditionVO> getElevatorByPrivateNum(String privateNum);

	/**
	 * 模糊搜素 单位内编号
	 * @param registerNumber 单位内编号
	 * @return 数据集
	 */
	List<ElevatorSearchConditionVO> getElevatorByRegisterNumber(String registerNumber);

	/**
	 * 模糊搜素  使用登记证
	 * @param equipmentRegisterNumber 使用登记证
	 * @return 数据集
	 */
	List<ElevatorSearchConditionVO> getElevatorByEquipmentRegisterNumber(String equipmentRegisterNumber);

	List<SidaElevatorBasicVO> getElevatorListByTenantId(String tenantId);

	List<GovernmentElevatorPoolVO> getUnMarkList(List<String> markedDeviceCodeList);

	List<GovernmentElevatorPoolVO> getUnMarkListFull();

    List<BIScreenElevatorVO> selectBIScreenBuildingElevator(String startDate, String endDate);

    List<BIScreenElevatorPlanVO> selectBIScreenBuildingElevatorWx(String startDate, String endDate);

    List<BIScreenElevatorPlanPartsVO> selectBuildingElevatorWxWork(String startDate, String endDate);

	List<BIScreenElevatorPlanPartsVO> selectBuildingElevatorPartsWork(String startDate, String endDate);

    List<ElevatorMaintainCostListDTO> selectElevatorMaintainCostList(List<Long> elevatorIds);

    int getMonitorElevatorCount(Date rangeEndDate);

	List<String> getElevatorPhones();

	void downExcelElevatorPrincipal_v2(ElevatorPrincipalQueryDTO queryDTO, List<List<String>> rows);

	List<SimpleElevatorInfoVO> listSimpleElevatorInfoByIds(List<Long> elevatorIds);

}



